<?php
header("content-type:text/html;charset=utf-8");
//$str='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$str='/01234567/89abcdef/ghijklmn/opqrstuv/wxyzABCD/EFGHIJKL/MNOPQRST/UVWXYZ';
function getname(){
	return mt_rand(1000, 9999)."-".mt_rand(1000, 9999)."-".mt_rand(1000, 9999);
}
function mkfile($path){
	global $str,$filelen,$filesum;
	$fs=$filesum*mt_rand(1, 10);
	$fl=$filelen*mt_rand(10, 100);
	for($j=0;$j<$fs;$j++){
		for($i=0;$i<$fl;$i++){
			$strff.=str_shuffle($str);
		}
		$gname=getname();
		$handle=fopen($path."/".$gname, "a+");
		$w=fwrite($handle, $strff);
		echo $gname."//".$w."<br>";
	}
}
//读取所有
function getdir($path){
	$arr=scandir($path);
	foreach($arr as $v){
		if($v!="."&&$v!=".."){
			if(is_dir($path."/".$v)){
				echo "目录：".$path."/".$v;
				mkfile($path."/".$v);
				echo "<br>";
				getdir($path."/".$v);
			}
		}
	}		
}

$filesum=$_POST['fs'];
$filelen=$_POST['fl'];
$path=$_POST['path'];
if(!empty($_POST['path'])&&!empty($_POST['fs'])&&!empty($_POST['fl'])&&!empty($_POST['hid'])){
	getdir($path);
}

?>
<html>
	<head>
		<meta charset="utf-8">
		<title>mkf</title>
	</head>
	<body>
		<form action="#" method="post">
			<br />
			<br />
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;输入dirname：
			<input type="text" name="path" value="<?php echo $_POST['path'];?>" /> <br />
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;输入fileSum：
			<input type="text" name="fs" value="<?php echo $_POST['fs'];?>" /> <br />
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;输入fileLen：
			<input type="text" name="fl" value="<?php echo $_POST['fl'];?>" /> <br />
			<input type="hidden" name="hid" id="hid" value="1" />
			<input style="margin-left: 300px;margin-top: 12px;" type="submit" value="MK start"/>
		</form>
		<br />
		<br />
		<h3>注：输入本程序文件的相对目标文件夹</h3>
		<br />
		<br />
	</body>
</html>